<%#
 Copyright 2008 Steven Barth <steven@midlink.org>
 Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
 Licensed to the public under the Apache License 2.0.
-%>



<%+header%>

<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
<script type="text/javascript" src="<%=resource%>/jquery/jquery-1.4.js"></script>

<script type="text/javascript">

	console.log("js ready!");

	function getLog() 
	{    
		<%
		function readFile(FileName)
			local f = io.open(FileName,"r")
			if(f == nil )then
			return ""  
			end
			local string = ''
			local str_end = '\\n'
			for line in f:lines() do
				string = string..line..str_end
			end
			f:close()  
			return string 
		
		end
		local log = readFile("/var/log/ztk_service.log.1")..readFile("/var/log/ztk_service.log")
		%>
		var log = "<%=log%>";
		return log;
	}

	function LogRefresh()
	{
		console.log("LogRefresh");
		//$('#syslog').val("");
		//$('#syslog').val(getLog());
		var log = getLog()
		$('#syslog').val("");
		$('#syslog').val(log);
	}

	$(document).ready(function()
	{		
		$('#syslog').val(getLog());
		setInterval(LogRefresh, 3000);
	});
</script>

<h2><a id="content" name="content"><%:Run Log%></a>
</h2>
<div id="content_syslog">
<textarea readonly="readonly" style="font-size: 12px;" wrap="off" rows="" id="syslog"></textarea>
</div>


<%+footer%>


